<table>
    <tr class="top">
        <td colspan="12" style="text-align:right;">
            <?php if($this->status == 2): ?>
                <img style="margin-bottom:-3px;margin-top:4px;" src="<?php echo $this->baseUrl(); ?>/images/icons/tick.png" /> = Setujui &nbsp;&nbsp;&nbsp;
            <?php endif; ?>
            <?php if($this->status < 5): ?>
                <img style="margin-bottom:-3px;margin-top:4px;" src="<?php echo $this->baseUrl(); ?>/images/icons/delete.png" /> = Batalkan
            <?php endif; ?>
        </td>
    </tr>
    <tr class="head">
        <td>Kode</td>
        <td>Pemesanan</td>
        <?php if($this->status <= 5): ?>
            <td>Toko</td>
            <td>Pembeli</td>
        <?php endif; ?>
            <td>Status</td>
        <?php if($this->status <= 5): ?>
            <td>Rincian</td>
            <td>Total</td>
        <?php endif; ?>
        <?php if($this->status == 2): ?><td>Pembayaran</td><?php endif; ?>
        <?php if($this->status == 4): ?><td>Pengambilan</td><?php endif; ?>
        <?php if($this->status > 5): ?><td>Alasan Pembatalan</td><?php endif; ?>
        <td><?php
            if($this->status < 5) echo "Update Terakhir";
            else if($this->status < 6) echo "Diterima";
            else echo "Pembatalan";
        ?></td>
        <?php if($this->status < 5): ?><td>Aksi</td><?php endif; ?>
    </tr>
    <?php
    foreach ($this->data as $val) {
    ?>
        <tr style="background-color: <?= $this->cycle(array("#ccffcc", "#99ff99"))->next(); ?>;">
            <td>
                <a id="link" href="<?php echo $this->url(array("controller" => "transaction", "action" => "details", "id" => $this->escape($val["transaction_id"]))); ?>">
                <?php echo $this->escape($val["code"]); ?>
            </a>
        </td>
        <td><?php echo date("d-M-Y", strtotime($val["date"])); ?></td>
        <?php if($this->status <= 5): ?>
            <td><?php echo $this->escape($val["s_name"]); ?></td>
            <td><?php echo $this->escape($val["b_name"]); ?></td>
        <?php endif; ?>
        <td><?php echo $this->escape($val["description"]); ?><?php if($this->status>5) echo "(".$val['transaction_status_id'].")"; ?></td>
        <?php if($this->status <= 5): ?>
            <td><?php echo $this->escape($val["details"]); ?></td>
            <td><?php echo $this->escape($val["total_payment"]); ?></td>
        <?php endif; ?>
        <?php if($this->status == 2): ?>
            <td><?php echo date("d-M-Y", strtotime($val["payment_date"])); ?></td>
        <?php endif; ?>
        <?php if($this->status == 4): ?>
            <td><?php echo date("d-M-Y", strtotime($val["delivery_date"])); ?></td>
        <?php endif; ?>
        <?php if($this->status > 5): ?>
            <td><?php echo $this->escape($val["cancel_reason"]); ?></td>
        <?php endif; ?>
        <td><?php echo date("d-M-Y", strtotime($val["last_update"])); ?></td>
        <?php if($this->status < 5): ?>
        <td>
            <?php if($this->status == 2): ?>
                <a href="javascript: accept(<?= $val["transaction_id"].",'". $val["code"]."'" ?>)" title="Setujui">
                    <img src="<?php echo $this->baseUrl(); ?>/images/icons/tick.png" alt="Setujui" />
                </a>&nbsp;
            <?php endif; ?>
            
            <a href="javascript: cancel(<?= $val["transaction_id"].",'". $val["code"]."',".$val["transaction_status_id"]?>)" title="Batalkan">
                <img src="<?php echo $this->baseUrl(); ?>/images/icons/delete.png" alt="Batalkan" />
            </a>
        </td>
        <?php endif; ?>
    </tr>
    <?php
            }
    ?>
</table>
<?php
    // navigator
    echo $this->back;
    echo $this->current;
    echo $this->next;
?>